<template>
	<view class="">
		<view class="con" v-if="!isLogin">
			<!-- <text class="tips">即将在后续版本开放</text> -->
			<view v-for="(item,index) in tongji_list" :key="index" class="tongji-list-box"
				:class="item.leixing==2?'chengfa':''">
				<text>{{`类型：${item.leixing==1?'奖励':'惩罚'}`}}</text>
				<text>{{`日期：${item.riqi}`}}</text>
				<text>{{`奖惩原因：${item.yuanyin}`}}</text>
				<text>{{`金额：${item.money}元`}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLogin: false,
				tongji_list: []
			}
		},
		methods: {
			//统计数据
			tongjiList() {
				uniCloud.callFunction({
					name: 'linghuaqian-tongji',
					data: {
						id: uni.getStorageSync('LOGIN')._id
					}
				}).then(res => {
					console.log('res', res.result.data)
					this.tongji_list = res.result.data
				})
			}
		},
		onShow() {
			console.log('show')
			this.isLogin = !uni.getStorageSync('LOGIN')
			if (!uni.getStorageSync('LOGIN')) {
				uni.showModal({
					content: '请先登录',
					showCancel: false,
					success: (res) => {
						if (res.confirm) {
							uni.switchTab({
								url: '/pages/my/my'
							})
						}
					}
				})


			}
			this.tongjiList()
		}
	}
</script>

<style lang="scss" scoped>
	.con {
		padding: 30rpx;
		display: flex;
		flex-direction: column;
	}

	.tips {
		font-size: 14px;
		color: brown;
	}

	.tongji-list-box {
		display: flex;
		flex-direction: column;
		margin-bottom: 30rpx;
		padding: 20rpx 0;
		// border-bottom: 1px solid #e9e9e9;
	}

	/* .tongji-list-box:nth-of-type(2n+1) {
		background: #f3f3f3;
	} */
	.chengfa {
		background: #f3c8c8;
	}
</style>
